package com.kk.bussiness.login.ui;

import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Button;
import org.zkoss.zul.Html;
import org.zkoss.zul.Vbox;

@SuppressWarnings("serial")
public class LoginWindow extends Vbox
{
	public LoginWindow()
	{
		this.setId("LOGIN_WINDOW");
		this.setWidgetListener("onKeyDown", "if(event.keyCode == 13){sendData();}");
		
		Html html = new Html();
		html.setContent("<div class=\"login-win-title-div\"><h2>登录系统</h2><div><br/>" + "<input id=\"user\" type=\"text\" class=\"form-control\" placeholder=\"登录名\" required autofocus/>"
				+ "<input id=\"psaw\" type=\"password\" class=\"form-control\" placeholder=\"密码\" required/>");
		this.appendChild(html);
		
		Button okBtn = new Button("登录");
		okBtn.setAutodisable("true");
		okBtn.setSclass("btn btn-lg btn-primary btn-block");
		okBtn.setId("BTN_LOGIN");
		okBtn.addEventListener(Events.ON_CLICK, new EventListener<Event>(){

			@Override
			public void onEvent(Event arg0) throws Exception
			{
				Clients.showBusy("正在进入系统，请稍后……");
				Executions.sendRedirect("../index.zul");
				
			}});
		this.appendChild(okBtn);
	}
}
